package com.youhp.spire.xls.demo.Charts.ManipulateChart;

import com.spire.xls.*;
import com.spire.xls.charts.ChartSerie;

import java.awt.*;

public class SetFont {

    public static void main(String[] args)
    {
        Workbook workbook = new Workbook();
        //Load file from disk
        workbook.loadFromFile("data/SetFont.xlsx");

        //Get the first sheet
        Worksheet sheet = workbook.getWorksheets().get(0);

        //Get the first sheet
        Chart chart = sheet.getCharts().get(0);

        //Create a font
        ExcelFont font = workbook.createFont();
        font.setSize(15.0);
        font.setColor(Color.lightGray);

        for (ChartSerie cs : (Iterable<ChartSerie>)chart.getSeries())
        {
            //Set font
            cs.getDataPoints().getDefaultDataPoint().getDataLabels().getTextArea().setFont(font);
        }

        //Save the result file
        workbook.saveToFile("output/SetFont.xlsx", ExcelVersion.Version2010);

    }
}
